home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / omniORB-2.5.0-src.tar.gz / omniORB-2.5.0-src.tar / omniORB_2.5.0 / include / omniORB2 / CORBA_basetypes.h < prev    next >
C/C++ Source or Header  |  1998-03-02  |  4KB  |  164 lines

  1. // -*- Mode: C++; -*-
  2. //                            Package   : omniORB2
  3. // CORBA_basetypes.h          Created on: 30/1/96
  4. //                            Author    : Sai Lai Lo (sll)
  5. //
  6. //    Copyright (C) 1996, 1997 Olivetti & Oracle Research Laboratory
  7. //
  8. //    This file is part of the omniORB library
  9. //
  10. //    The omniORB library is free software; you can redistribute it and/or
  11. //    modify it under the terms of the GNU Library General Public
  12. //    License as published by the Free Software Foundation; either
  13. //    version 2 of the License, or (at your option) any later version.
  14. //
  15. //    This library is distributed in the hope that it will be useful,
  16. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18. //    Library General Public License for more details.
  19. //
  20. //    You should have received a copy of the GNU Library General Public
  21. //    License along with this library; if not, write to the Free
  22. //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
  23. //    02111-1307, USA
  24. //
  25. //
  26. // Description:
  27. //    *** PROPRIETORY INTERFACE ***
  28.  
  29. /*
  30.  $Log: CORBA_basetypes.h,v $
  31.  * Revision 1.7  1998/03/02  14:05:02  ewc
  32.  * Patch to fix IDL unions containing structs which contain floats or doubles
  33.  * (was broken on OpenVMS).
  34.  *
  35.  * Revision 1.6  1998/01/21  12:12:17  sll
  36.  * New function _CORBA_null_string_ptr.
  37.  *
  38.  * Revision 1.5  1998/01/20  16:45:45  sll
  39.  * Added support for OpenVMS.
  40.  *
  41.  Revision 1.4  1997/08/21 22:21:38  sll
  42.  New extern function _CORBA_use_nil_ptr_as_nil_objref().
  43.  
  44.  * Revision 1.3  1997/05/06  16:05:20  sll
  45.  * Public release.
  46.  *
  47.  */
  48.  
  49. #ifndef __CORBA_BASETYPES_H__
  50. #define __CORBA_BASETYPES_H__
  51.  
  52. #ifdef HAS_Cplusplus_Bool
  53. typedef bool                      _CORBA_Boolean;
  54. #else
  55. typedef unsigned char             _CORBA_Boolean;
  56. #endif
  57.  
  58. typedef unsigned char             _CORBA_Char;
  59.  
  60. typedef unsigned char             _CORBA_Octet;
  61.  
  62. typedef short                     _CORBA_Short;
  63.  
  64. typedef unsigned short            _CORBA_UShort;
  65.  
  66. #if SIZEOF_LONG == 4
  67. typedef long                      _CORBA_Long;
  68.  
  69. typedef unsigned long             _CORBA_ULong;
  70. #elif SIZEOF_INT == 4
  71. typedef int                       _CORBA_Long;
  72.  
  73. typedef unsigned int              _CORBA_ULong;
  74. #else
  75. # error "Can't map Long (32 bits) to a native type."
  76. #endif
  77.  
  78. #ifndef NO_FLOAT
  79.  
  80. #if defined(__VMS) && !__IEEE_FLOAT
  81.  
  82. // VMS does not use IEEE floating point unless __IEEE_FLOAT is defined
  83. #define USING_PROXY_FLOAT
  84.  
  85. #include <cvtdef.h>
  86. extern "C" unsigned int cvt$convert_float(...);
  87.  
  88. class _CORBA_Float {
  89.   _CORBA_Long pd_f;
  90.   inline void cvt_(float f) {
  91.     int status=
  92.     cvt$convert_float(&f,CVT$K_VAX_F,&pd_f,CVT$K_IEEE_S,CVT$M_ROUND_TO_NEAREST);
  93.     assert(status &1);
  94.   }
  95.   inline float cvt_() const {
  96.     float f;
  97.     int status=
  98.     cvt$convert_float(&pd_f,CVT$K_IEEE_S,&f,CVT$K_VAX_F,CVT$M_ROUND_TO_NEAREST);
  99.     assert(status & 1);
  100.     return f;
  101.   }
  102. public:
  103.   // using compiler generated copy constructor and copy assignment
  104.   _CORBA_Float() : pd_f(0) {
  105.   }
  106.   _CORBA_Float(float f) {
  107.     cvt_(f);
  108.   }
  109.   operator float() const {
  110.     return cvt_();
  111.   }
  112. };
  113.  
  114. class _CORBA_Double {
  115.   _CORBA_Long pd_d[2];
  116. #if __D_FLOAT
  117.     enum {NativeFmt = CVT$K_VAX_D};
  118. #elif __G_FLOAT
  119.     enum {NativeFmt = CVT$K_VAX_G};
  120. #else
  121. #error "Illegal floating point format defined (must use IEEE, D or G)."
  122. #endif  // D vs G float
  123.   inline void cvt_(double d) {
  124.     int status=
  125.     cvt$convert_float(&d,NativeFmt,&pd_d,CVT$K_IEEE_T,CVT$M_ROUND_TO_NEAREST);
  126.     assert(status &1);
  127.   }
  128.   inline float cvt_() const {
  129.     double d;
  130.     int status=
  131.     cvt$convert_float(&pd_d,CVT$K_IEEE_T,&d,NativeFmt,CVT$M_ROUND_TO_NEAREST);
  132.     assert(status & 1);
  133.     return d;
  134.   }
  135. public:
  136.   // using compiler generated copy constructor and copy assignment
  137.   _CORBA_Double() {
  138.     memset(&pd_d, 0, sizeof(pd_d));
  139.   }
  140.   _CORBA_Double(double d) {
  141.     cvt_(d);
  142.   }
  143.   operator double() const {
  144.     return cvt_();
  145.   }
  146. };
  147.  
  148. #else
  149.  
  150.  
  151. // This platform uses IEEE float
  152. typedef float                     _CORBA_Float;
  153. typedef double                    _CORBA_Double;
  154.  
  155. #endif   // VMS float test
  156. #endif   // !defined(NO_FLOAT)
  157.  
  158. extern void _CORBA_new_operator_return_null();
  159. extern void _CORBA_bound_check_error();
  160. extern void _CORBA_marshal_error();
  161. extern _CORBA_Boolean _CORBA_use_nil_ptr_as_nil_objref();
  162. extern void _CORBA_null_string_ptr(_CORBA_Boolean);
  163. #endif // __CORBA_BASETYPES_H__
  164.